#include "Processpool.hpp"
#include "Task.hpp"

void Usage(string str)
{
    cout << "Usage: " << str << "process-num" << endl;
}

int main(int argc, char *argv[])
{
    // 指定管道数
    if (argc != 2)
    {
        Usage(argv[0]);
        return USAGE_ERROR;
    }
    int num = stoi(argv[1]);
    ProcessPool *pp = new ProcessPool(num, Worker);

    // 1.初始化进程池
    pp->InitProcesspool();

    // 2.轮巡派发任务
    pp->DispatchTask();

    // 3.退出进程池
    pp->CleanProcessPool();

    delete pp;
    return 0;
}